package com.eastedu.repository.ktree.po;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastedu.common.enums.Section;
import com.eastedu.common.enums.SubjectType;
import com.eastedu.entity.jdbc.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import lombok.*;
import org.hibernate.Hibernate;

import java.util.Objects;

/**
 * KnowledgeRootPO
 * 根知识节点表
 *
 * @author LiuLei
 */
@Entity
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "t_knowledge_root")
public class KnowledgeRootPO extends BaseEntity<KnowledgeRootPO> {
    /**
     * 唯一标识符
     */
    @TableField(value = "guid")
    private String guid;

    /**
     * 知识点名称
     */
    @TableField(value = "`name`")
    private String name;

    /**
     * 备注
     */
    @TableField(value = "remark")
    @Column(name = "remark", columnDefinition = "varchar(1000) COMMENT '备注'")
    private String remark;

    /**
     * 创建用户ID
     */
    @TableField(value = "create_user_id")
    @Column(name = "create_user_id", nullable = false, columnDefinition = "bigint(20) COMMENT '创建用户ID'")
    private Long createUserId;

    /**
     * 学段CODE
     */
    @TableField(value = "section")
    @Column(name = "section", nullable = false, columnDefinition = "varchar(10) COMMENT '学段'")
    private Section section;

    /**
     * 科目CODE
     */
    @TableField(value = "subject")
    @Column(name = "subject", nullable = false, columnDefinition = "varchar(10) COMMENT '学科'")
    private SubjectType subject;

    /**
     * 是否可用
     */
    @TableLogic(value = "1", delval = "0")
    @TableField(value = "available", fill = FieldFill.INSERT)
    private Boolean available;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
            return false;
        }
        KnowledgeRootPO root = (KnowledgeRootPO) o;
        return getId() != null && Objects.equals(getId(), root.getId());
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
